/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.example.mgd;

import com.example.ejb.ConfigSessionLocal;
import com.example.entity.MdlVideoconferenciacfg;
import com.icesoft.faces.component.ext.HtmlInputText;
import com.icesoft.faces.component.ext.RowSelectorEvent;

import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.html.HtmlDataTable;
import javax.faces.event.ActionEvent;

/**
 *
 * @author andres
 */
@ManagedBean
@SessionScoped
public class ConfigMgdBean {
    @EJB
    private ConfigSessionLocal configSession;
    private MdlVideoconferenciacfg config;

    private HtmlDataTable table;
    private HtmlInputText hostInput;
    private HtmlInputText portInput;
    private String host;
    private Integer port;
   

    /** Creates a new instance of ConfigMgdBean */
    public ConfigMgdBean() {
    }

    public List getRecords(){
        return configSession.retrieve();
    }

    public MdlVideoconferenciacfg getDetails(){
        return config;
    }

    public String showDetails(MdlVideoconferenciacfg config){
        this.config = config;
        return "";
    }

    public void update(ActionEvent e){
        config.setHost(getHost());
        config.setPort(getPort());
        configSession.update(config);
    }

    public void remove(ActionEvent e){
        config.setHost(getHost());
        config.setPort(getPort());
        configSession.delete(config);
    }

    public void meter(ActionEvent e){
        config = new MdlVideoconferenciacfg();
        config.setHost(getHost());
        config.setPort(getPort());
        configSession.add(config);
    }

    public void selection(RowSelectorEvent e){
        config = (MdlVideoconferenciacfg) table.getRowData();
        this.port = config.getPort();
        this.host = config.getHost();
    }

    public HtmlDataTable getTable() {
        return table;
    }

    public void setTable(HtmlDataTable table) {
        this.table = table;
    }

     public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    public HtmlInputText getHostInput() {
        return hostInput;
    }

    public void setHostInput(HtmlInputText hostInput) {
        this.hostInput = hostInput;
    }

    public HtmlInputText getPortInput() {
        return portInput;
    }

    public void setPortInput(HtmlInputText portInput) {
        this.portInput = portInput;
    }

  

}
